package ar.com.utn.openqsb.main;

import java.awt.AlphaComposite;
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics2D;
import java.awt.SplashScreen;

/**
 * Splash screen of the application.
 * 
 * @author rvega
 * @author aprieto
 */
public class Splash implements Runnable {

	private SplashScreen splash;

	private Graphics2D g;

	/**
	 * {@inheritDoc}
	 */
	public void run() {
		splash = SplashScreen.getSplashScreen();
		g = splash.createGraphics();
	}

	/**
	 * close splash screen.
	 */
	public void close() {
		splash.close();
	}

	/**
	 * Write a state message into the splash screen.
	 * 
	 * @param message
	 *            Message to write.
	 */
	public void renderMessage(String message) {
		g.setComposite(AlphaComposite.Clear);
		g.fillRect(0, 0, 400, 40);
		g.setPaintMode();
		g.setColor(Color.BLACK);
		g.setFont(new Font("arial", 0, 12));
		g.drawString(message, 70, 80);
		splash.update();
	}
}
